import request from '@/common/js/request.js'

export default {
	// 查询指定位置的广告信息
	getAdvertList() {
		return request({
			url: `/api/carousel/list`,
			data: {
				currentPage: 1,
				pageSize: 7
			}
		})
	},

	// 查询分类与标签信息
	getCategoryList() {
		return request({
			url: '/api/type/list',
			data: {
				currentPage: 1,
				pageSize: 10
			}
		})
	},

	// 条件分页查询课程列表 query条件对象{isFree: 0}，current当前页码，size每页显示多少条
	getList(query, currentPage, pageSize) {
		return request({
			url: '/api/course/list',
			method: 'GET',
			data: {
				...query,
				currentPage,
				pageSize
			} // {isFree: 0, current: current, size: size}
		})
	},
	
	//通过课程ID查询课程基本信息
	getCourseById(id){
		return request({
			url: `/api/course/getByIdList?id=${id}`,
			method: 'GET',
		})
	},
	//通过课程ID查询章节列表数据
	getChapterSectionList(id){
		return request({
			url: `/api/chapter/list?id=${id}`,
			method: 'GET',
		})
	},
	
	//通过课程ID查询课程评论列表数据
	getCourseCommentList(id){
		return request({
			url: `/api/commont/list?id=${id}`,
			method: 'GET',
		})
	},
	
	//通过课程ID查询组合套餐
	getCourseGroupList(id){
		return request({
			url: `/api/group/getByIdList/${id}`,
			method: 'GET',
		})
	},
	
	//通过课程id和用户id查询该课程是否购买
	getBuyCourse(userId,courseId){
		return request({
			url: `/api/butcourse/list`,
			data: {
				userId,
				courseId
			},
			method: 'GET',
		})
	},
	
	//提交评价内容
	getAppraise(data){
		return request({
			url: `/api/commont`,
			method: 'POST',
			data
		})
	},
	
	// 查询我的学习列表
	getCourseStudyList(userId) {
		return request({
			url: `/api/course/myStudy?userId=${userId}`,
			method: 'GET'
		})
	}
	
}
